const path = require('path')
const {
	CleanWebpackPlugin
} = require('clean-webpack-plugin');
const VueLoaderPlugin = require('vue-loader/lib/plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const webpackDevServer = require('webpack-dev-server')
module.exports = {
	mode: 'development',
	entry: {
		app: './src/main.js',
	},
	output: {
		filename: 'bundle.js',
		path: path.join(__dirname, 'dist')
	},
	module: {
		rules: [{
			test: /\.vue$/,
			use: [{
				loader: 'vue-loader',
			}]
		}, {
			test: /\.less$/,
			use: [{
				loader: 'style-loader'
			}, {
				loader: 'css-loader'
			}, {
				loader: 'less-loader'
			}]
		}, {
			test: /.css$/,
			use: [{
					loader: 'style-loader'
				},
				{
					loader: 'css-loader',
					options: {
						modules: true
					}
				}
			]
		}]
	},
	plugins: [
		new HtmlWebpackPlugin({
			title: '测试',
			template: path.join(__dirname, 'public/index.html'),
			filename: './index.html',
			BASE_URL: './'
		}),
		new VueLoaderPlugin(),
		// new CleanWebpackPlugin(),
		new ExtractTextPlugin("styles.css"),
		new CopyPlugin({
			patterns: [{
				from: 'public',
				to: path.join(__dirname, 'dist'),
				globOptions: {
					ignore: ['/public/index.html']
				}
			}]
		})
	],
	devServer: {
		contentBase: path.join(__dirname, "dist"),
		compress: true,
		port: 9000
	}
}
